import re

# # match 从字符开头匹配 返回match对象
# r = re.match('aaa', 'aabbb')
# print(r)
# r = re.match('aaa', 'aaabbb')
# print(r, r.group())


# # fullmatch 整个字符串完全匹配 返回match对象
# r = re.match('aaa', 'aaab')
# print(r)
# r = re.match('aaa', 'aaa')
# print(r, r.group())


# # sub 替换匹配项, 返回替换后字符串
# r = re.sub('aa', 'bb', 'aabb')
# print(r)


# # subn 替换并返回替换次数
# r, count = re.subn('b', 'a', 'bbb')
# print(r, count)


# # split 根据模式分隔字符串
# r = re.split(r' ', 'hello re')
# print(r)
# # 使用多个分隔符
# r = re.split(r'[,;| ]', 'hello re|1,2;3 4 5')
# print(r)
# # 分割同时也分割分隔符
# r = re.split(r'([,;| ])', 'hello re|1,2;3 4 5')
# print(r)
# # 限制分割次数, 但是分割分隔符不算次数
# r = re.split(r'([,;| ])', 'hello re|1,2;3 4 5', maxsplit=3)
# print(r)


# # finditer 返回匹配迭代器
# matches = re.finditer(r'\w{4}', 'aaaa, bbbb, cccc')
# for match in matches:
#     print(match.group())



# # 正则表达式标志（flags）
# # re.S/re.DOTALL 让 . 匹配包括换行符在内的所有字符
# text = """第一行
# 第二行
# 第三行"""
# result = re.search(r'.+', text)
# print(result)
# result = re.search(r'.+', text, re.S)
# print(result)
# result = re.search(r'.+', text, re.DOTALL)
# print(result)


# # re.I / re.IGNORECASE 忽略大小写
# text = 'AaAAaAaa'
# result = re.findall(r'A', text)
# print(result)
# result = re.findall(r'A', text, re.I)
# print(result)
# result = re.findall(r'A', text, re.IGNORECASE)
# print(result)


# # re.M / re.MULTILINE 多行模式
# text = """第一行: hello
# 第二行: world
# 第三行: hello again"""
# # ^ 只匹配字符串开头
# result = re.findall(r'^\w+', text)
# print(result)
#
# result = re.findall(r'^\w+', text, re.M)
# print(result)
#
# result = re.findall(r'^\w+', text, re.MULTILINE)
# print(result)


# # re.A / re.ASCII - ASCII 模式
# text = "hello 世界 123"
# result = re.findall(r'\w+', text)
# print(result)
# result = re.findall(r'\w+', text, re.A)
# print(result)  # 不匹配中文
# result = re.findall(r'\w+', text, re.ASCII)
# print(result)  # 不匹配中文

print(response.text)
detail_img = re.findall(r'<div class="info-area">.*?src="(.*?)".*?</div>', response.text, re.S)
detail_title = re.findall(r'<div class="info-area">.*?<strong>(.*?)</strong>.*?</div>', response.text, re.S)
detail_info = re.findall(r'<span class="all hidden">(.*?)<br/>(.*?)</span>', response.text, re.S)
print(detail_img, detail_title, detail_info)